
import java.util.Date;
import javax.microedition.lcdui.ChoiceGroup;
//import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.DateField;
import javax.microedition.lcdui.Form;
//import javax.microedition.lcdui.List;
import javax.microedition.lcdui.TextField;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author VO CHI DUNG
 */
public class AddWork {

    public AddWork(PlanTable p)
    {
        parent = p;

        frm = new Form("Them");
        work = new TextField("Cong Viec", "", 15, TextField.ANY);
        date = new DateField("Date & Time", DateField.DATE_TIME);
        date.setDate(new Date());
        
        choiceGroup = new ChoiceGroup("Importance", ChoiceGroup.EXCLUSIVE);

        choiceGroup.append("rat quan trong", null);
        choiceGroup.append("Quan Trong", null);
        choiceGroup.append("Binh thuong", null);
        choiceGroup.append("Khong can thiet", null);

        frm.append(work);
        frm.append(date);
        frm.append(choiceGroup);

        frm.addCommand(GlobalVariableStatic.CMD_BACK);
        frm.addCommand(GlobalVariableStatic.CMD_OK);

        frm.setCommandListener(parent);
    }

    public Form GetForm()
    {
        return frm;
    }

    public void reset()
    {
        date.setDate(new Date());
        work.setString("");
        choiceGroup.setSelectedIndex(0, true);
    }

    public void HandleInput(Command c)
    {
         if(GlobalVariableStatic.CMD_BACK == c)
         {
            parent.Switch(GlobalVariableStatic.MENU);
         }
         else if(GlobalVariableStatic.CMD_OK == c)
         {
            parent.dataTask.insert(new RecordTask(work.getString(), date.getDate().getTime(),choiceGroup.getSelectedIndex(),"", ""));
            parent.updateListWork();
            parent.Switch(GlobalVariableStatic.LISTWORK);
         }
    }

    private Form frm;
    private PlanTable parent;
    TextField work;
    DateField date;
    ChoiceGroup choiceGroup;

}
